﻿@{
	ViewBag.Title = @Resources.CheckVisaInfo;
}
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
	<tr>
		<td class="b1">
			<div>
				<p><img src="~/images/icon_06.png" align="absmiddle" />&nbsp;@Resources.Menu_UserCenter<span>&nbsp;>>&nbsp;</span>@Resources.CheckVisaInfo
			</div>
		</td>
	</tr>
	<tr>
		<td class="b4">
			<div class="c">
				<div class="right" id="mainFrame">
					<div class="right_cont">
						<div id="dataGrid"></div>
						<div id="toolBar">
							<div id="searchBar">
								<div style="float: left; display: inline; padding: 5px 5px; font-weight: bold; text-align: left;">
									@Resources.ConferenceName：<input id="queryConferenceName" name="queryConferenceName" class="easyui-textbox" style="height:27px; width:200px;">&nbsp;&nbsp;
									<a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData()">@Resources.Search </a>
								</div>
							</div>
							<div id="menuBar"></div>
							<div class="clear"></div>
						</div>
					</div>
				</div>
			</div>
		</td>
	</tr>
</table>
<div id="detailWindow" class="easyui-window"
	title="@Resources.ConferenceVisa" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="detailWindowTitle" class="tit01"></h3>
			<form id="frmDetail" method="post" >
				<table width="100%" height="100%" id="tblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">First Name：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-firstname" name="firstName" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
							<input type="hidden" id="hidConferenceId"  name="conferenceId"/>
							<input type="hidden" id="conferenceAttendId" name="conferenceAttendId" />
						</td>
						<td style="text-align: right;" class="w1 c1">Last Name：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-familyname" name="familyName" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">Title：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-title" name="title" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,validType:['length[1,100]']" />
						</td>
						<td style="text-align: right;" class="w1 c3">Affiliation：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-affiliation" name="affiliation" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">Country：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-country" name="country" class="easyui-combobox" style="height:27px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c1"></td>
						<td style="text-align: left;" class="w2 c2"></td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">State/Province：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-state" name="state" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c3"></td>
						<td style="text-align: left;" class="w2 c4"></td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">City：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-city" name="city" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c1"></td>
						<td style="text-align: left;" class="w2 c2"></td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">Zip/Postal Code：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-postcode" name="zipCode" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
						</td>
						<td style="text-align: right;" class="w1 c3"></td>
						<td style="text-align: left;" class="w2 c4"></td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">Address：</td>
						<td style="text-align: left;" class="w2 c2" colspan="3">
							<input id="v-address" name="address" class="easyui-textbox" style="height:27px; width:884px;" data-options="required:true,validType:['length[1,200]']" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">Email：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-email" name="mail" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['email','length[1,100]']" />
						</td>
						<td style="text-align: right;" class="w1 c3">Telephone：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-telephone" name="telephone" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">Birthdate：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-birthdate" name="birthday" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true" />
						</td>
						<td style="text-align: right;" class="w1 c1">Gender：</td>
						<td style="text-align: left;" class="w2 c2">
							<select id="v-gender" name="gender" class="easyui-combobox" style="height:27px; width:300px;" data-options="editable:false,required:true,panelHeight:'auto'">
								<option value="Male">Male</option>
								<option value="Female">Female</option>
							</select>
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">Passport No.：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-passportNum" name="passportNum" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true" />
						</td>
						<td style="text-align: right;" class="w1 c3">Passport Issue Country：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-countryOfIssue" name="countryOfIssue" class="easyui-textbox" style="height:27px; width:300px;" data-options="required:true,validType:['length[1,100]']" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">Passport Issue Date：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-issueDate" name="issueDate" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true" />
						</td>
						<td style="text-align: right;" class="w1 c1">Passport Expiry Date：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="v-expiryDate" name="expiryDate" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">Arrival Date：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-arrivalDate" name="arrivalDate" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true" />
						</td>
						<td style="text-align: right;" class="w1 c3">Departural Date：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="v-departuralDate" name="departuralDate" class="easyui-datebox" style="height:27px; width:300px;" data-options="editable:false,required:true" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">Remark：</td>
						<td style="text-align: left;" class="w2 c2" colspan="3">
							<input id="v-remark" name="remark" class="easyui-textbox" style="height:50px; width:884px;" data-options="multiline:true,validType:['length[1,1000]']" />
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="button" id="saveData" class="gbtn" onclick="saveData();" value="@Resources.Save" />&nbsp;&nbsp;
				<input type="button" class="rbtn" onclick="$('#detailWindow').window('close');" value="@Resources.Cancel" />
			</div>
		</div>
	</div>
</div>

@section Scripts {
<script>
	var windowHeight = $(window).height() - 200;
	$("#mainFrame").css("height", (windowHeight)+"px");

	$(function () {
		$("#queryConferenceName").textbox("textbox").bind("keydown", function (e) {
			if (e.keyCode == 13) {
				searchData()
			}
		});

		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(ProfileVisaController.GetData), nameof(ProfileVisaController).GetControllerName())",
			method: "get",
			fitColumns: true,
			singleSelect: true,
			width: 1200,
			height: $(window).height() - 110,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			toolbar: "#toolBar",
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			columns: [[
				{
					field: "conferenceName", title: "@Resources.ConferenceName", align: "center", sortable: true, width: 180,
					formatter: function (value, rec) {
			    			var conStr = ""
			    			if (rec.homePageUrl != null && rec.homePageUrl != "") {
			    				conStr += "<a href=' "+ rec.homePageUrl +" ' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  "
			    			} else {
			    				var tmp = rec.conferenceNickName == null ? "" : rec.conferenceNickName.replace(new RegExp("'",'g'),"’").replace(new RegExp('"','g'),"“");
			    				conStr += "<a href='@Url.Action(nameof(MeetingMainController.Index), nameof(MeetingMainController).GetControllerName())"
									+ "/" + tmp + "' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  ";
			    			}
			    			return conStr;
					}
				},
				{ field: "fullName", title: "@Resources.FullName", align: "center", sortable: true, width: 200 },
				{
					field: "status", title: "@Resources.HasApplyVisa", align: "center", sortable: true, width: 100,
					formatter: function (value, rec) {
			    			if (value != "@ConstValues.InvitationStatus.未申请") {
			    				var strInfo = "<a href='#' style='color:#1874CD;text-decoration:underline;' onclick='readDetail(\"" + rec.conferenceAttendId + "\",\"" + rec.sendStatus + "\",\"" + rec.conferenceId + "\")'>" + "@Resources.HasInvitated" + "</a>  ";
			    				return strInfo;

			    			} else {
			    				var strInfo = "<a href='#' style='color:#1874CD;text-decoration:underline;' onclick='invitate(\"" + rec.conferenceAttendId + "\",\"" + rec.conferenceId + "\")'>" + "@Resources.HasNotInvitated" + "</a>  ";
			    				return strInfo;
			    			}
					}
				},
				{ field: "sendStatus", title: "@Resources.VisaInvitation", align: "center", sortable: true, width: 100 },
				{
					field: "download", title: "@Resources.DownloadInvitation", align: "center", width: 100,
					formatter: function (value, rec) {
			    			if (rec.sendStatus != "@ConstValues.SendStatus.已发送") {
			    				return "@ConstValues.strHyphen@ConstValues.strHyphen"
			    			} else {
			    				var link = "";
			    				link +="<a href='@Url.Action(nameof(ProfileVisaController.DownloadInvitation),
									nameof(ProfileVisaController).GetControllerName())";
			    				link += "?conferenceAttendId=" + rec.conferenceAttendId;
			    				link += "' class='downloadLink' style='color:#1874CD'>" + "@Resources.Download" + "</a>";
			    				return link;
			    			}
					}
				},
			]]
		});

		$("#detailWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			height: 800,
			top: 100
		});
	});

	function searchData() {
		$("#dataGrid").datagrid("load", {
			queryConferenceName: $("#queryConferenceName").textbox("getValue"),
		});
	}

	function invitate(conferenceAttendId, conferenceId) {
		var language = "";
		@if (Request.Cookies["_culture"] == null) {
			<text>
			language = "@((User as ICISPrincipal).Language)";
			</text>
		}
		else {
			<text>
			language = "@Request.Cookies["_culture"].Value";
			</text>
		}

		$("#v-country").combobox({
			url: "@Url.Action(nameof(UtilityController.GetCountryEn), nameof(UtilityController).GetControllerName())",
			valueField: "id",
			textField: "name",
			required: true,
		});

		$("#v-title").combobox({
			url: "@Url.Action(nameof(UtilityController.GetTitle), nameof(UtilityController).GetControllerName())" + "?conferenceId=" + conferenceId,
			valueField: "id",
			textField: "name",
			editable: false,
			required: true,
			panelHeight: "auto",
		});

		$("#v-familyname").textbox("setValue", "");
		$("#v-firstname").textbox("setValue", "");
		$("#v-title").combobox("setValue", "");
		$("#v-country").combobox("setValue", "");
		$("#v-state").textbox("setValue", "");
		$("#v-city").textbox("setValue", "");
		$("#v-postcode").textbox("setValue", "");
		$("#v-affiliation").textbox("setValue", "");
		$("#v-email").textbox("setValue", "");
		$("#v-telephone").textbox("setValue", "");
		$("#v-birthdate").datebox("setValue", "");
		$("#v-gender").textbox("setValue", "");
		$("#v-address").textbox("setValue", "");
		$("#v-countryOfIssue").textbox("setValue", "");
		$("#v-passportNum").textbox("setValue", "");
		$("#v-issueDate").datebox("setValue", "");
		$("#v-expiryDate").datebox("setValue", "");
		$("#v-arrivalDate").datebox("setValue", "");
		$("#v-departuralDate").datebox("setValue", "");
		$("#v-remark").textbox("setValue", "");

		$("#conferenceAttendId").val(conferenceAttendId);
		$("#hidConferenceId").val(conferenceId);
		$("#saveData").show();
		$("#detailWindow").window("open")
	}

	function saveData() {
		var isValid = $("#frmDetail").form("validate");
		if (isValid) {
			$.messager.confirm("@Resources.Submit", "@Resources.CfmInvitate", function (r) {
				if (r) {
					var loading = layer.load(0,  {
						shade: [0.4,"#fff"]
					});
					$.post("@Url.Action(nameof(ProfileVisaController.SaveData), nameof(ProfileVisaController).GetControllerName())",
						$("#frmDetail").serialize(),
						function(data, textStatus, jqXHR) {
							layer.close(loading);
							if (data.result == "@ConstValues.AjaxFailResult") {
								common.showError(data.message);
							} else {
								common.showSuccess(data.message, true);
								$("#detailWindow").window("close");
								$("#dataGrid").datagrid("reload");
							}
						}
					);
				}
			})
		}
	}

	function readDetail(attendId, sendStatus, conferenceId) {
		var url = "@Url.Action(nameof(ProfileVisaController.GetInvoiceUserData),
				nameof(ProfileVisaController).GetControllerName())" + "?attendId=" + attendId;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxSuccessResult") {
				$("#v-familyname").textbox("setValue", data.data.familyName);
				$("#v-firstname").textbox("setValue", data.data.firstName);

				$("#v-title").combobox({
					url: "@Url.Action(nameof(UtilityController.GetTitle), nameof(UtilityController).GetControllerName())" + "?conferenceId=" + conferenceId,
					valueField: "id",
					textField: "name",
					required: true,
					editable: false,
					panelHeight: "auto",
				});
				$("#v-title").combobox("setValue", data.data.title);

				$("#v-country").combobox({
					url: "@Url.Action(nameof(UtilityController.GetCountryEn), nameof(UtilityController).GetControllerName())",
					valueField: "id",
					textField: "name",
					required: true,
				});
				$("#v-country").combobox("setValue", data.data.country);
				$("#v-state").textbox("setValue", data.data.state);
				$("#v-city").textbox("setValue", data.data.city);

				$("#v-postcode").textbox("setValue", data.data.zipCode);
				$("#v-affiliation").textbox("setValue", data.data.affiliation);
				$("#v-email").textbox("setValue", data.data.mail);
				$("#v-telephone").textbox("setValue", data.data.tele);
				$("#v-birthdate").datebox("setValue", data.data.birthday);
				$("#v-gender").textbox("setValue", data.data.gender ? "Male" : "Female");
				$("#v-address").textbox("setValue", data.data.address);
				$("#v-countryOfIssue").textbox("setValue", data.data.issueOfCountry);
				$("#v-passportNum").textbox("setValue", data.data.passportNum);
				$("#v-issueDate").datebox("setValue", data.data.dateOfIssue);
				$("#v-expiryDate").datebox("setValue", data.data.expiryDate);
				$("#v-arrivalDate").datebox("setValue", data.data.arrivalDate);
				$("#v-departuralDate").datebox("setValue", data.data.departuralDate);
				$("#v-remark").textbox("setValue", data.data.remark);

				if (sendStatus == "@ConstValues.SendStatus.未发送") {
					$("#saveData").show();
				} else {
					$("#saveData").hide();
				}
				$("#conferenceAttendId").val(attendId);
				$("#detailWindow").window("open")
			};
		});
	}

	function downloadInvitation(conferenceAttendId) {
		var url = "@Url.Action(nameof(ProfileVisaController.DownloadInvitation),
				nameof(ProfileVisaController).GetControllerName())" +"?conferenceAttendId=" + conferenceAttendId;
		$.get(url, null, function (data, textStatus, jqXHR) {
		});
	}
</script>
}